package com.loveyukari.service;

import java.util.Date;
import java.util.List;

import com.loveyukari.utils.AliDayuUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.loveyukari.dao.XmMessageDao;
import com.loveyukari.model.XmMessage;

/**
*
*yangshaohua
*2017年2月1日下午4:46:10
**/
@Service
public class XiaomaService {
	 
	@Autowired
	private XmMessageDao xmMessageDao; 

	public void addMessage(String msg,String name){
		XmMessage xmMessage = new XmMessage();
		xmMessage.setCreateTime(new Date());
		xmMessage.setMessage(msg.replace("\n", "</br>"));
		xmMessage.setName(name);
		xmMessageDao.insertXmMessage(xmMessage);
		if ("小缘".equals(name)){
			AliDayuUtils.sendMeLiuyan(msg);
		}
	}
	
	public List<XmMessage> getMessage(Integer size){
		List<XmMessage> list = xmMessageDao.selectXmMessageBySize(size);
		return list;
	}
	
	public XmMessage getMessageByXmLast(String name){
		XmMessage xmMessage = xmMessageDao.selectXmMessageByLast(name);
		return xmMessage;
	}
	
}
